package com.lrkj.payfee.controller;

import io.swagger.annotations.ApiOperation;
import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.lrkj.common.annotation.Log;
import com.lrkj.common.core.controller.BaseController;
import com.lrkj.common.core.domain.AjaxResult;
import com.lrkj.common.enums.BusinessType;
import com.lrkj.payfee.domain.Refill;
import com.lrkj.payfee.service.IRefillService;
import com.lrkj.common.utils.poi.ExcelUtil;
import com.lrkj.common.core.page.TableDataInfo;

/**
 * 充值类型Controller
 *
 * @author yajun_ren
 * @date 2021-07-27
 */
@RestController
@RequestMapping("/payfee/refill")
public class RefillController extends BaseController
{
    @Autowired
    private IRefillService refillService;

    /**
     * 查询充值类型列表
     */
    @ApiOperation(value = "查询充值类型列表", notes = "查询充值类型列表")
    @GetMapping("/list")
    public TableDataInfo list(Refill refill)
    {
        startPage();
        List<Refill> list = refillService.selectRefillList(refill);
        return getDataTable(list);
    }

    /**
     * 导出充值类型列表
     */
	@ApiOperation(value = "导出充值类型列表", notes = "导出充值类型列表")
    @PreAuthorize("@ss.hasPermi('payfee:refill:export')")
    @Log(title = "充值类型", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(Refill refill)
    {
        List<Refill> list = refillService.selectRefillList(refill);
        ExcelUtil<Refill> util = new ExcelUtil<Refill>(Refill.class);
        return util.exportExcel(list, "充值类型数据");
    }

    /**
     * 获取充值类型详细信息
     */
	@ApiOperation(value = "获取充值类型详细信息", notes = "获取充值类型详细信息")
    @PreAuthorize("@ss.hasPermi('payfee:refill:query')")
    @GetMapping(value = "/{refillId}")
    public AjaxResult getInfo(@PathVariable("refillId") String refillId)
    {
        return AjaxResult.success(refillService.selectRefillById(refillId));
    }

    /**
     * 新增充值类型
     */
	  @ApiOperation(value = "新增充值类型", notes = "新增充值类型")
    @PreAuthorize("@ss.hasPermi('payfee:refill:add')")
    @Log(title = "充值类型", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Refill refill)
    {
        return toAjax(refillService.insertRefill(refill));
    }

    /**
     * 修改充值类型
     */
	 @ApiOperation(value = "修改充值类型", notes = "修改充值类型")
    @PreAuthorize("@ss.hasPermi('payfee:refill:edit')")
    @Log(title = "充值类型", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Refill refill)
    {
        return toAjax(refillService.updateRefill(refill));
    }

    /**
     * 删除充值类型
     */
	 @ApiOperation(value = "删除充值类型", notes = "删除充值类型")
    @PreAuthorize("@ss.hasPermi('payfee:refill:remove')")
    @Log(title = "充值类型", businessType = BusinessType.DELETE)
	@DeleteMapping("/{refillIds}")
    public AjaxResult remove(@PathVariable String[] refillIds)
    {
        return toAjax(refillService.deleteRefillByIds(refillIds));
    }
}
